home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_313 / uucp / uucp1.lzh / src / lib / setstdin.c < prev    next >
C/C++ Source or Header  |  1990-01-10  |  815b  |  40 lines

  1.  
  2. /*
  3.  *  SETSTDIN.C
  4.  *
  5.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  6.  *
  7.  *  Sets stdin, stdout, and stderr to UUSER: handler
  8.  */
  9.  
  10. #include <stdio.h>
  11.  
  12. SetStdin(ac, av)
  13. char *av[];
  14. {
  15.     short i;
  16.     short getty = 0;            /*  from getty    */
  17.     char *device = "serial.device";     /*  device name */
  18.     long unit = 0;            /*  unit no.    */
  19.     char buf[64];
  20.     FILE *f1, *f2, *f3;
  21.  
  22.     for (i = 1; i < ac; ++i) {
  23.     char *ptr = av[i];
  24.     if (*ptr != '-')
  25.         continue;
  26.     if (ptr[1] == 'D')
  27.         device = av[++i];
  28.     if (ptr[1] == 'U')
  29.         unit = atoi(av[++i]);
  30.     if (ptr[1] == 'G')
  31.         getty = 1;
  32.     }
  33.     sprintf(buf, "UUSER:%s/%d/R1000G%d", device, unit, getty);
  34.     f1 = freopen(buf, "r", stdin);
  35.     f2 = freopen(buf, "w+", stdout);
  36.     f3 = freopen(buf, "w+", stderr);
  37.     return(f1 && f2 && f3);
  38. }
  39.  
  40.